<template>
  <div>
    <el-dialog
      title="跟进"
      :visible="visible"
      width="568px"
      @close="$emit('close')"
    >
      <el-form
        :model="form"
        ref="form"
        :rules="rules"
        label-width="80px"
        :inline="false"
        size="normal"
      >
        <el-form-item label="跟进内容" prop="content">
          <el-input type="textarea" v-model="form.content"></el-input>
        </el-form-item>
        <el-form-item label="值班日期" prop="followUpTime">
          <el-date-picker
            v-model="form.followUpTime"
            value-format="yyyy-MM-dd"
            type="date"
            placeholder="选择日期"
            :picker-options="pickerOptions"
          >
          </el-date-picker>
        </el-form-item>
      </el-form>

      <span slot="footer">
        <el-button type="primary" @click="click('确认')">确认</el-button>
        <el-button type="primary" @click="click('确认并解除预警')"
          >确认并解除预警</el-button
        >
        <el-button @click="$emit('close')">取消</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'detailDialog',
  props: {
    visible: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      form: {},
      rules: {
        content: [{ required: true, message: '请输入内容', trigger: 'change' }],
        followUpTime: [
          { required: true, message: '请输入时间', trigger: 'change' }
        ]
      },
      pickerOptions: {
        disabledDate (date) {
          return date.getTime() > Date.now()
        }
      }
    }
  },
  methods: {
    click (key) {
      const rf = this.$refs.form
      rf.validate((valid) => {
        if (valid) {
          this.form.key = key
          this.$emit('click', this.form)
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
